package com.byght.bygsystem.mapper;

import com.byght.bygsystem.model.Personnel;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PersonnelMapper {

    @Select("SELECT * FROM personnel")
    List<Personnel> findAll();

    @Select("SELECT * FROM personnel WHERE id = #{id}")
    Personnel findById(int id);

    @Insert("INSERT INTO personnel(name, role, phone) VALUES(#{name}, #{role}, #{phone})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Personnel personnel);

    @Update("UPDATE personnel SET name = #{name}, role = #{role}, phone = #{phone} WHERE id = #{id}")
    void update(Personnel personnel);

    @Delete("DELETE FROM personnel WHERE id = #{id}")
    void delete(int id);
}
